]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
util: Import notifyError dynamically when needed
authorSam Spilsbury <sam@endlessm.com>
Tue, 13 Jun 2017 16:43:20 +0000 (00:43 +0800)
committerMarge Bot <marge-bot@gnome.org>
Tue, 21 May 2024 13:42:28 +0000 (13:42 +0000)
For unit tests, it is best not to pull in UI related code.

https://bugzilla.gnome.org/show_bug.cgi?id=783738

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3164>

js/misc/util.js

index 508c87d24cf4080e561cffb5622c400aa3cb0a6e..161733b5d2e1b105797659488633ff232f902008 100644 (file)
@@ -6,7 +6,6 @@ import Shell from 'gi://Shell';
 import St from 'gi://St';
 import GnomeDesktop from 'gi://GnomeDesktop';
 
-import * as Main from '../ui/main.js';
 import {formatTime} from './dateUtils.js';
 
 // http://daringfireball.net/2010/07/improved_regex_for_matching_urls
@@ -184,8 +183,10 @@ export function trySpawnCommandLine(commandLine) {
 }
 
 function _handleSpawnError(command, err) {
-    let title = _('Execution of ā€œ%sā€ failed:').format(command);
-    Main.notifyError(title, err.message);
+    const title = _('Execution of ā€œ%sā€ failed:').format(command);
+    // Use dynamic import to not pull in UI related code in unit tests
+    import('../ui/main.js').then(
+        ({notifyError}) => notifyError(title, err.message));
 }
 
 /**